package day5;

public class Demo9 {
    public static void swap2(int a,int b) {
        System.out.println("交换前：a: " + a + ",b: " + b);
// 一个数 异或 另一个数 2次，结果是自己
        a = a ^ b;
        b = a ^ b; // a^b^b ==> a
        a = a ^ b; // a^b^a ==> b;
        System.out.println("交换后：a: " + a + ",b: " + b);}

    public static void main(String[] args) {
        int x = 10;
        int y = 20;
        swap2(x,y);
        System.out.println("--------------");
        swap2(30,40);}
}
